const path = require('path');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
module.exports = merge(common, {
    mode: 'development',
    devtool: 'eval-cheap-source-map',
    plugins: [
        // 在 plugins 数组中添加：
        new HtmlWebpackPlugin({
            template: './public/index.html',
            title: process.env.APP_TITLE || '默认标题' // 读取环境变量
        }),
        new webpack.DefinePlugin({
            'process.env.APP_TITLE': JSON.stringify(process.env.APP_TITLE)
        }),

    ],
    devServer: {
        static: {
            directory: path.join(__dirname, 'dist'),
        },
        port: 3000,
        open: true,
        hot: true
    }
}
);
